import React, { Component } from 'react';
import { Select, Input, Button, Radio, Icon } from 'antd';
import styles from './index.less';
import { isAuthMenuByConfig } from '../SiderMenu/SiderMenuUtils';
import { appConfig } from '@/appConfig';
import isEmpty from 'lodash/isEmpty';
import isObject from 'lodash/isObject';

const Option = Select.Option;
const InputGroup = Input.Group;

class ChoiceHeader extends Component {

  constructor(props) {
    super(props);
    // 判断是否有“文件中心”权限
    this.hadDocAuth = false;
    const userInfo = props.userInfo || {};
    const userAuthResObj = userInfo.resources;
    if (!isEmpty(userAuthResObj) && isObject(userAuthResObj)) {
      this.hadDocAuth = isAuthMenuByConfig(appConfig.DOCUMENT.authConfig, userAuthResObj);
    }
  }

  handleChange = (value) => {
    console.log(`selected ${value}`);
  };

  handleBlur = () => {
    console.log('blur');
  };

  handleFocus = () => {
    console.log('focus');
  };

  render() {
    const { isMobile } = this.props;
    return (
      <InputGroup style={{ display: 'inline' }}>
        {
          // isMobile ? null : (
          //   <>
          //     <span className={styles.headerTipNumber}>2019年第1期</span>
          //     <Select
          //       disabled={true}
          //       addonBefore="Http://"
          //       showSearch
          //       style={{ minWidth: 150 }}
          //       className="header-company-sel"
          //       placeholder="请选择"
          //       optionFilterProp="children"
          //       onChange={this.handleChange}
          //       onFocus={this.handleFocus}
          //       onBlur={this.handleBlur}
          //       defaultValue="广州石油1"
          //       filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
          //     >
          //       <Option value="广州石油1">广州石油1</Option>
          //       <Option value="广州石油2">广州石油2</Option>
          //       <Option value="广州石油3">广州石油2</Option>
          //     </Select>
          //   </>
          // )
        }
        <div className={styles.headerTopBtn} style={isMobile ? { marginLeft: -16 } : {}}>
          {
            this.hadDocAuth && (
              <Button size={isMobile ? 'small' : 'default'} className={styles.handleBtn} type="primary" onClick={() => {
                window.open('./#/recdCenter', '_blank');
              }}><Icon type="diff"/>文件中心</Button>
            )
          }

          {/*<Button size={isMobile ? 'small' : 'default'} className={styles.handleBtn} type="primary"><Icon*/}
          {/*  type="file-search"/>帮助中心(开发中)</Button>*/}
        </div>

      </InputGroup>
    );
  }
}

export default ChoiceHeader;
